package shufflecards;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;


public class Test2 {

    public static List<List<Card>> dealCards(List<Card> list){
        List<List<Card>> hand = new LinkedList<>();
        List<Card> hand1 = new LinkedList<>();
        List<Card> hand2 = new LinkedList<>();
        List<Card> hand3 = new LinkedList<>();
        hand.add(hand1);
        hand.add(hand2);
        hand.add(hand3);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                hand.get(j).add(list.remove(0));
            }
        }
        return hand;
    }

    public static void swap(List<Card> list,int lift,int right){
        Card tmp = list.get(lift);
        list.add(lift,list.get(right));
        list.add(right,tmp);
    }
    public static List<Card> suffle(List<Card> list){
        Random random = new Random();
        for (int i = list.size()-1; i > 0; i--) {
            int index = random.nextInt(i);
            swap(list,i,index);
        }
        return list;
    }
    public static void main(String[] args) {
        CardList cardList = new CardList();
        List<Card> list = cardList.buyCard();
        List<List<Card>> hand = dealCards(list);
        for (int i = 0; i < hand.size(); i++) {
            System.out.println(hand.get(i));
        }
    }
}
